home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-08-28 | 4.5 KB | 185 lines | [TEXT/MPS ] |
- /*------------------------------------------------------------------------------
- #
- # osmain.c
- #
- # Example of a rather minimal A/ROSE download file
- #
- # The "ClientAppli" application will find "myTask" on a MCP card,
- # and have the messages sent to it echoed.
- #
- # Components:
- # osmain.c
- # myTask.c
- #
- ------------------------------------------------------------------------------*/
-
-
- /* -------------- MPW: select the following lines + <ENTER> ------
-
- C osmain.c -r
- C myTask.c -r
- Link -t 'DMRP' -c 'RWM ' ∂
- osmain.c.o ∂
- myTask.c.o ∂
- ::OS.o ∂
- ::osglue.o ∂
- -o start
-
- ::Download start
- ---------------------------------------------------------------- */
-
-
- // the following definitions come from the A/ROSE include file "os.h"
-
- typedef long tid_type;
-
- struct ST_Registers
- {
- long D_Registers [8]; // D0 - D7
- long A_Registers [8]; // A0 - A7 Note: A7 not used
- long PC; // Program Counter
- };
-
- struct ST_PB
- {
- char *CodeSegment; // memory region on card for code
- char *DataSegment; // memory region on card for global data
- char *StartParmSegment; // memory region on card for start parameters
- struct ST_Registers InitRegs; // initial register set for starting task
- long stack; // initial stack size (in bytes)
- long heap; // initial heap size (in bytes)
- short return_code; // error code if task not started (Tid = 0)
- unsigned char priority; // priority of task (in bytes)
- tid_type ParentTID; // TID of Parent on Network/Host
- };
-
- typedef struct ST_PB ST_PB;
-
-
-
- // the following declarations come from arose.h
-
- typedef unsigned long OSlong;
- typedef unsigned short OSshort;
- typedef unsigned char OSchar;
-
- // gCommon - A/ROSE common data area
-
- struct gCommon // Located at 0x400 on the MCP card
- {
- OSshort gRelease; // release and version number
- OSchar gProcessor; // Type of processor
- OSchar gCardRun; // Set zero by download, non-zero by O/S
- OSshort gBoardID; // Board id of card
- OSlong gTID; // Current Task ID
- OSchar gDebugOn; // non-zero if debugger running
- OSchar gMajorFlag; // major processing flag
- OSlong gInitA5; // Initial A5
- // ................
- // many, many other fields contained in this structure: look up in arose.h !
- // ................
- };
-
- typedef struct gCommon gCommon;
-
- #define cMaxMsg 500 // Maximum number of messages
- #define cOSStack 4096 // size of OS Stack
-
- // the following two lines come from siop.h
-
- #define TICKS_PS 19 // 19 ticks per second
- #define TICK_MIN_MAJ 8 // 8 minor ticks per major tick
-
- // prototypes
-
- void osinit ();
- void osstart ();
- void name_server ();
- void ICCM ();
- void myTask ();
- extern tid_type GetTID();
- extern struct gCommon *GetgCommon();
- extern tid_type StartTask(struct ST_PB *);
-
- void StartNameServer(ST_PB *pb); // the Name Manager
- void StartICCManager(ST_PB *pb); // you guess it!
- void StartmyTask(ST_PB *pb); // and our sample task
-
-
- pascal void illegal ()
- extern 0x4afc;
-
- main ()
- {
- struct ST_PB stpb; // Start parameter block
-
- // Init OS with cMaxMsg messages and cStackOS stack
-
- osinit (cMaxMsg, cOSStack);
-
- StartNameServer(&stpb); // the Name Manager
- StartICCManager(&stpb); // you guess it!
- StartmyTask(&stpb); // and our sample task
-
- // start all other required managers and tasks
-
-
- osstart (TICK_MIN_MAJ, TICKS_PS); // Start operating system
-
- illegal (); // should never get here!
-
- } // main()
-
-
- void StartNameServer(ST_PB *pb)
- // priority 31, 4k stack, 0 heap
- {
- pb -> CodeSegment = 0;
- pb -> DataSegment = 0;
- pb -> StartParmSegment = 0;
- pb -> stack = 4096;
- pb -> heap = 0;
- pb -> priority = 31;
- pb -> InitRegs.PC = name_server;
- pb -> InitRegs.A_Registers [5] = GetgCommon() -> gInitA5;
- pb -> ParentTID = GetTID();
-
- if (StartTask (pb) == 0)
- illegal ();
- }
-
- void StartICCManager(ST_PB *pb)
- // priority 31, 128-byte stack, 0 heap
- {
- pb -> CodeSegment = 0;
- pb -> DataSegment = 0;
- pb -> StartParmSegment = 0;
- pb -> stack = 128;
- pb -> heap = 0;
- pb -> priority = 31;
- pb -> InitRegs.PC = ICCM;
- pb -> InitRegs.A_Registers [5] = GetgCommon() -> gInitA5;
- pb -> ParentTID = GetTID();
-
- if (StartTask (pb) == 0)
- illegal ();
- }
-
-
- void StartmyTask(ST_PB *pb)
- // priority 10, 4k stack, 0 heap
- {
- pb -> CodeSegment = 0;
- pb -> DataSegment = 0;
- pb -> StartParmSegment = 0;
- pb -> InitRegs.A_Registers [5] = GetgCommon() -> gInitA5;
- pb -> ParentTID = GetTID();
- pb -> stack = 4096;
- pb -> heap = 0;
- pb -> priority = 10;
- pb -> InitRegs.PC = myTask; // entry point of myTask
-
- if (StartTask (pb) == 0) // if the task does not get started
- illegal (); // go debugging
- }
-